home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / bin / gifcompose < prev    next >
Text File  |  2006-01-09  |  2KB  |  120 lines

  1. #!/bin/sh
  2. #
  3. # gifcompose --- a GIF compositor
  4. #
  5. # This script composes a GIF from a series of overlays described in an input
  6. # text file.
  7. #
  8. if [ "$1" = "-v" ]
  9. then
  10.     echo=echo
  11. else
  12.     echo=:
  13. fi
  14.  
  15. trap "rm -fr comp$$ tmp$$ btmp$$; exit 0" 0 1 2 15
  16.  
  17. mkdir comp$$;
  18.  
  19. gen="x"
  20. while read line
  21. do
  22.     set -- $line
  23.     postproc='n'
  24.     name=$2
  25.     case $1 in
  26.     gif)
  27.         $echo "Pasting GIF file $2.gif" 1>&2;
  28.         cat $2.gif >tmp$$
  29.         shift; shift; postproc='y' ;;
  30.     raw)
  31.         $echo "Pasting raw file $2" 1>&2;
  32.         raw2gif -s $3 $4 <$2 >tmp$$
  33.         shift; shift; shift; shift; postproc='y' ;;
  34.     rgb)
  35.         $echo "Pasting RGB file $2" 1>&2;
  36.         rgb2gif -s $3 $4 <$2 >tmp$$
  37.         shift; shift; shift; shift; postproc='y' ;;
  38.     rle)
  39.         $echo "Pasting RLE file $2" 1>&2;
  40.         rle2gif $2 >tmp$$
  41.         shift; shift; postproc='y' ;;
  42.     text)
  43.         $echo "Generating text \`$2'" 1>&2;
  44.         case "$3" in
  45.         foreground)
  46.             text2gif -t "$2" -f $4 >tmp$$;
  47.             shift; shift;;
  48.         background)
  49.             text2gif -t "$2" -c $4 $5 $6 >tmp$$;
  50.             shift; shift; shift; shift;;
  51.         *)
  52.             text2gif -t "$2" >tmp$$;;
  53.         esac
  54.         shift; shift; postproc='y' ;;
  55.     screen)
  56.         case $2 in
  57.         size) resize="$3 $4";;
  58.         position) reposition="$3 $4";;
  59.         *) echo "Unknown screen operation" 1>&2
  60.         esac;;
  61.     esac
  62.  
  63.     if [ $postproc = 'y' ]
  64.     then
  65.         while [ $# != 0 ]
  66.         do
  67.             case "$1" in
  68.             at)
  69.                 $echo "Positioning \`$name' at $2 $3" 1>&2
  70.                 gifpos -i $2 $3 <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  71.                 shift; shift; shift;;
  72.             clip)
  73.                 $echo "Clipping \`$name' to size $2 $3 $4 $5" 1>&2
  74.                 gifclip -i $2 $3 $4 $5 <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  75.                 shift; shift; shift; shift; shift;;
  76.             xflip)
  77.                 $echo "Flipping \`$name' around the X axis" 1>&2;
  78.                 gifflip -x <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  79.                 shift;;
  80.             yflip)
  81.                 $echo "Flipping \`$name' around the Y axis" 1>&2;
  82.                 gifflip -y <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  83.                 shift;;
  84.             left)
  85.                 $echo "Rotating \`$name' left (counterclockwise)" 1>&2;
  86.                 gifflip -l <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  87.                 shift;;
  88.             right)
  89.                 $echo "Rotating \`$name' right (clockwise)" 1>&2;
  90.                 gifflip -r <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  91.                 shift;;
  92.             ''|\#*)
  93.                 break;;
  94.             *)
  95.                 echo "Unknown operator \`$1'" 1>&2
  96.                 shift;;
  97.             esac
  98.         done
  99.  
  100.         mv tmp$$ comp$$/${gen}.gif
  101.     fi
  102.  
  103.     gen="${gen}x";
  104. done
  105.  
  106. gifasm comp$$/*.gif | gifovly -t 0 >tmp$$
  107. if [ "$resize" ]
  108. then
  109.     gifpos -s $resize <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  110. fi
  111. if [ "$reposition" ]
  112. then
  113.     gifpos -n $reposition <tmp$$ >btmp$$; mv btmp$$ tmp$$;
  114. fi
  115. cat tmp$$
  116.  
  117. $echo "Done."
  118.  
  119. # script ends here
  120.